<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="http://localhost:85/?type=mgr" --><!DOCTYPE xsl:stylesheet  [
	<!ENTITY nbsp   "&#160;">
	<!ENTITY copy   "&#169;">
	<!ENTITY reg    "&#174;">
	<!ENTITY trade  "&#8482;">
	<!ENTITY mdash  "&#8212;">
	<!ENTITY ldquo  "&#8220;">
	<!ENTITY rdquo  "&#8221;"> 
	<!ENTITY pound  "&#163;">
	<!ENTITY yen    "&#165;">
	<!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">

<xsl:variable name="catid" select="/root/para/@catid" />
<xsl:variable name="page" select="/root/para/@page" />
<xsl:variable name="pagesize" select="/root/para/@pagesize" />

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title><xsl:value-of select="/root/category/cat[@id=/root/para/@catid]" />--我的收藏夹</title>
<base target="_self" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
<style type="text/css">
html,body { overflow:hidden}
form { margin:0; padding:0}
</style>
<script type="text/javascript">
<xsl:comment>
document.onkeydown = function(){
	if(event.keyCode==27){
		window.close();
	}
}
function selectAll(obj){
	var s = obj.checked;
	var chks = document.getElementById("fav").getElementsByTagName("input");
	for(var i=0,j; j=chks[i]; i++){
		j.checked = s;
	}
}
function moveFav(){
	var chks = document.getElementById("fav").getElementsByTagName("input");
	var id = [];
	for(var i=0,j; j=chks[i]; i++){
		if(j.checked){
			id.push(j.value);
		}
	}
	if(id.length>0){
		var n = window.showModalDialog("?type=movetocat&amp;ids="+id.join(",")+"&amp;"+Math.random(),window,"dialogWidth:300px; dialogHeight:180px; help:0");
		if(n==1){
			//location.reload();
			setTimeout(function(){document.forms["form2"].submit();},10);
		}
	}else{
		alert("请勾选收藏记录。");
	}
}
function deleteFav(){
	var chks = document.getElementById("fav").getElementsByTagName("input");
	var id = [];
	for(var i=0,j; j=chks[i]; i++){
		if(j.checked){
			id.push(j.value);
		}
	}
	if(id.length>0){
		if(!confirm("确定要删除所选的 "+id.length+" 条记录吗？")){return;}
		setTimeout(function(){document.forms["form2"].submit();},10);
	}else{
		alert("请勾选收藏记录。");
	}
}
function CatMgr(){
	var n = window.showModalDialog("?type=catmgr&amp;"+Math.random(),window,"dialogWidth:550px; dialogHeight:352px; help:0");	
	if(n==1){
		setTimeout(function(){document.forms["refresh"].submit();},10);
	}
}
function CatAdd(){
	document.forms["form1"].catname.value = "";
	setTimeout(function(){
		document.forms["form1"].catname.focus();
	},1);
	document.getElementById("catadd").style.visibility = "visible";
	document.getElementById("cataddBox").style.visibility = "visible";	
}
function closeCatAdd(){
	document.getElementById("catadd").style.visibility = "hidden";
	document.getElementById("cataddBox").style.visibility = "hidden";
	setTimeout(function(){document.forms["form2"].submit();},10);
}
function Import(){
	var n = window.showModalDialog("?type=import&amp;"+Math.random(),window,"dialogWidth:450px; dialogHeight:252px; help:0");	
	if(n==1){
		setTimeout(function(){document.forms["refresh"].submit();},10);
	}
}
</xsl:comment>
</script>
</head>
<body>
<div class="mgr">
	<div class="header">
		<h1><xsl:value-of select="/root/username" /></h1>
        <form name="search" id="search" method="post" action="?type=search">
		<div class="toplink"><input type="text" name="keyword" id="keyword" class="keyword" /><input type="button" value="搜索" class="search" /> <a href="javascript:void(0)" onclick="Import()">导入收藏</a> | <a href="?type=logout">退出</a></div>
        </form>
    </div>
    <div class="main">
    	<table border="1" width="100%" cellpadding="4" cellspacing="0" bordercolor="#607e94">
        	<tr>
            	<th>分类</th>
                <th>
                	<span class="tool" onmouseover="document.getElementById('actionMenu').style.visibility='visible'" onmouseout="document.getElementById('actionMenu').style.visibility='hidden'">
                    	选择操作...
                    	<div class="actionMenu" id="actionMenu">
                        	<a href="#" onclick="moveFav(this)">移动到指定分类</a>
                            <a href="#" onclick="deleteFav(this)">删除所选</a>
                        </div>
                    </span>
                	<input type="checkbox" style="width:15px; height:15px; margin-right:3px" onclick="selectAll(this)" id="selectAll" /><label for="selectAll">收藏</label>
                </th>
            </tr>
        	<tr>
            	<td width="150" valign="top">
                	<ul class="catlist">
                    	<li>
                        	<xsl:element name="a">
                                <xsl:attribute name="href">?type=mgr&amp;page=1&amp;catid=0</xsl:attribute>
                                <xsl:if test="$catid=0">
                                <xsl:attribute name="class">cur</xsl:attribute>
                                </xsl:if>
                                <xsl:value-of select="string('未分类')"/>
                            </xsl:element><em>(<xsl:value-of select="count(/root/favorites/fav)" />)</em>
                        </li>
                        <xsl:call-template name="getCatTree">
                        	<xsl:with-param name="folder" select="/root/favorites" />
                            <xsl:with-param name="catid" select="$catid" />
                        </xsl:call-template>
                        <li>
                        	<xsl:element name="a">
                                <xsl:attribute name="href">?type=mgr&amp;page=1&amp;catid=-1</xsl:attribute>
                                <xsl:if test="$catid=-1">
                                <xsl:attribute name="class">cur</xsl:attribute>
                                </xsl:if>
                                <xsl:value-of select="string('全部收藏')"/>
                            </xsl:element><em>(<xsl:value-of select="count(/root/favorites//fav)" />)</em>
                        </li>
                    </ul>
                </td>                
                <td valign="top" height="420">                	
                	<form method="post" name="form2" id="form2" action="?type=removefav">
                    <input type="hidden" name="cid" value="{$catid}" />
                	<table border="1" cellpadding="0" cellspacing="0" width="100%" class="fav" id="fav" bordercolor="#506778" frame="void" rules="rows">
                    	<xsl:choose>
		                   	<xsl:when test="$catid=-1">
								<xsl:for-each select="/root/favorites//fav">
                                <xsl:if test="position()&gt;($pagesize * (number($page)-1)) and position()&lt;=($pagesize * $page)">
                                <xsl:call-template name="FavList">
                                    <xsl:with-param name="fav" select="." />
                                </xsl:call-template>                        
                                </xsl:if>
                                </xsl:for-each>                            
                            </xsl:when>
                            <xsl:when test="$catid=0">
								<xsl:for-each select="/root/favorites/fav">
                                <xsl:if test="position()&gt;($pagesize * (number($page)-1)) and position()&lt;=($pagesize * $page)">
                                <xsl:call-template name="FavList">
                                    <xsl:with-param name="fav" select="." />
                                </xsl:call-template>                        
                                </xsl:if>
                                </xsl:for-each>                            
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:for-each select="/root/favorites//folder[@guid=$catid]	/fav">
                                <xsl:if test="position()&gt;($pagesize * (number($page)-1)) and position()&lt;=($pagesize * $page)">
                                <xsl:call-template name="FavList">
                                    <xsl:with-param name="fav" select="." />
                                </xsl:call-template>                        
                                </xsl:if>
                                </xsl:for-each>
                            </xsl:otherwise>
                        </xsl:choose>
                    </table>
                    </form>
                </td>
            </tr>
            <tr>
            	<td><a href="javascript:void(0)" class="green" onclick="CatAdd()"><strong>+</strong>添加分类</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" onclick="CatMgr()">分类管理</a></td>
                <td>
                	<xsl:variable name="catetotal">
                	<xsl:choose>
                    	<xsl:when test="$catid=-1">
                        	<xsl:value-of select="count(/root/favorites//fav)" />
                        </xsl:when>
                        <xsl:when test="$catid=0">
                        	<xsl:value-of select="count(/root/favorites/fav)" />
                        </xsl:when>
                        <xsl:otherwise>
        			       	<xsl:value-of select="count(/root/favorites//folder[@guid=$catid]/fav)" />		                	
                    	</xsl:otherwise>
                    </xsl:choose>
                    </xsl:variable>
                    <xsl:variable name="maxpage" select="ceiling($catetotal div $pagesize)" />
                    页码:<xsl:value-of select="$page"/>/<xsl:value-of select="$maxpage" />,
					<span class="page">翻页:
                    <xsl:call-template name="PageNumber">
                    	<xsl:with-param name="catid" select="$catid" />
                        <xsl:with-param name="page" select="$page" />
                        <xsl:with-param name="maxpage" select="$maxpage" />
                    </xsl:call-template>
                    </span>
                </td>
            </tr>
        </table>
    </div>
</div>
<div id="catadd" style="visibility:hidden"></div>	
    <div class="cataddBox" id="cataddBox" style="visibility:hidden">
        <form method="post" action="?type=catadd" name="form1">
        <input type="text" name="catname" maxlength="10" />
        <button type="submit">添加分类</button>
        <div>
        	新添加的分类可以在“分类管理”中调整它的位置<br /><a href="javascript:void(0)" class="green" style=" text-decoration:underline" onclick="closeCatAdd()">关闭</a>
        </div>
        </form>
    </div>
<form name="refresh" id="refresh" method="post">
<input type="hidden" name="catid" id="catid" value="{/root/para/@catid}" />
<input type="hidden" name="page" id="page" value="{/root/para/@page}" />
<input type="hidden" name="pagesize" id="pagesize" value="{/root/para/@pagesize}" />
</form>
</body>
</html>

</xsl:template>

<xsl:template name="PageNumber">
<xsl:param name="catid" />
<xsl:param name="page" />
<xsl:param name="maxpage" />
	<xsl:variable name="end">
        <xsl:choose>        
            <xsl:when test="ceiling($page div 10)*10 &lt; $maxpage">    	        	
                <xsl:value-of select="ceiling($page div 10)*10" />
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$maxpage" />
            </xsl:otherwise>
	    </xsl:choose>
    </xsl:variable>
	<xsl:call-template name="LoopNumber">
	    <xsl:with-param name="catid" select="$catid" />
        <xsl:with-param name="page" select="$page" />
    	<xsl:with-param name="start" select="(ceiling($page div 10)-1)*10+1" />        
        <xsl:with-param name="end" select="$end" />
    </xsl:call-template>
    <span class="np">
    <xsl:if test="(ceiling($page div 10)-1)*10+1 &gt; 10">
    	<a href="?type=mgr&amp;page={(ceiling($page div 10)-2)*10+1}&amp;catid={$catid}">&lt;&lt;上10页</a>
    </xsl:if>
    <xsl:if test="$maxpage &gt; $end">
    	<a href="?type=mgr&amp;page={$end+1}&amp;catid={$catid}">下10页&gt;&gt;</a>
    </xsl:if>
    </span>
</xsl:template>

<xsl:template name="LoopNumber">
<xsl:param name="catid" />
<xsl:param name="page" />
<xsl:param name="start" />
<xsl:param name="end" />	
	<xsl:element name="a">
    	<xsl:attribute name="href">?type=mgr&amp;page=<xsl:value-of select="$start" />&amp;catid=<xsl:value-of select="$catid" /></xsl:attribute>
        <xsl:if test="$start=$page">
        <xsl:attribute name="class">curpage</xsl:attribute>
        </xsl:if>
        <xsl:value-of select="$start" />
    </xsl:element> 
    <xsl:if test="$start &lt; $end">
    	<xsl:call-template name="LoopNumber">
        	<xsl:with-param name="catid" select="$catid" />
            <xsl:with-param name="page" select="$page" />
            <xsl:with-param name="start" select="number($start)+1" />
            <xsl:with-param name="end" select="$end" />
        </xsl:call-template>
    </xsl:if>
</xsl:template>

<xsl:template name="FavList">
<xsl:param name="fav" />
<tr>
    <td class="f"><input type="checkbox" value="{$fav/@id}" name="fid" title="{position()}" /><a href="{$fav/@url}" title="{$fav/@title}&#13;{$fav/@url}" target="_blank"><xsl:value-of select="$fav/@title" /></a></td>
    <td><span><xsl:value-of select="$fav/@addtime" /></span></td>
</tr>
</xsl:template>

<xsl:template name="getCatTree">
	<xsl:param name="folder" />
    <xsl:param name="catid" />
    <xsl:for-each select="$folder/folder">
        <li>
            <xsl:element name="a">
                <xsl:attribute name="href">?type=mgr&amp;page=1&amp;catid=<xsl:value-of select="@guid" /></xsl:attribute>
                <xsl:if test="@default=1">
                	<xsl:attribute name="style">text-decoration:underline</xsl:attribute>
                </xsl:if>
                <xsl:if test="@guid=$catid">
                	<xsl:attribute name="class">cur</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="@name" />                
            </xsl:element>
            <em>(<xsl:value-of select="count(.//fav)" />)</em>
            <xsl:if test="./folder">
            	<ul>
            	<xsl:call-template name="getCatTree">
                	<xsl:with-param name="folder" select="." />
                    <xsl:with-param name="catid" select="$catid" />
                </xsl:call-template>
                </ul>
            </xsl:if>
        </li>
    </xsl:for-each>
</xsl:template>

</xsl:stylesheet>